<!DOCTYPE html>
<html>
    {include file="Widgets/head" /}
    <body class="gray-bg">
        <div class="wrapper wrapper-content animated fadeInUp">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox">
                        <div class="ibox-title">
                            <h3>借款管理-车贷</h3>
                        </div>
                        <div class="ibox-content">
                            <div class="row m-b-sm m-t-sm">
                                <div class="row">
                                    {if ($type_car)}
                                    <a href="{:url('Management/car', ['type'=>1])}" class="col-lg-offset-1 btn btn-white btn-lg col-lg-2">
                                        车贷（<font color="red">{$num_car}</font>）
                                    </a>
                                    {/if}
                                    {if ($type_consume)}
                                    <a href="{:url('Management/consume', ['type'=>2])}" class="col-lg-offset-1 btn btn-white btn-lg col-lg-2">
                                        消费金融（<font color="red">{$num_consume}</font>）
                                    </a>
                                    {/if}
                                    {if ($type_enterprise)}
                                    <a href="{:url('Management/enterprise', ['type'=>3])}"class="col-lg-offset-1 btn btn-white btn-lg col-lg-2">
                                        其他类（<font color="red">{$num_enterprise}</font>）
                                    </a>
                                    {/if}
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="row">
                                    <a href="{:url('Management/car', ['type'=>1,'status'=>'all'])}" class="col-sm-offset-1 btn btn-white btn-sm col-sm-1">
                                        全部（{$all}）
                                    </a>
                                    <a href="{:url('Management/car', ['type'=>1,'status'=>0])}" class="col-sm-offset-1 btn btn-white btn-sm col-sm-1">
                                        未售（{$status_0}）
                                    </a>
                                    <a href="{:url('Management/car', ['type'=>1,'status'=>1])}" class="col-sm-offset-1 btn btn-white btn-sm col-sm-1">
                                        募集中（{$status_1}）
                                    </a>
                                    <a href="{:url('Management/car', ['type'=>1,'status'=>2])}" class="col-sm-offset-1 btn btn-white btn-sm col-sm-1">
                                        还款中（{$status_2}）
                                    </a>
                                    <a href="{:url('Management/car', ['type'=>1,'status'=>3])}" class="col-sm-offset-1 btn btn-white btn-sm col-sm-1">
                                        已还款（{$status_3}）
                                    </a>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <form action="{:url('Management/car')}" method="post" class="form-horizontal">
                                    <input id="page-now" value="1" name="page_ajax" hidden>
                                    <input type="hidden" id="type" name="type" value="1">
                                    <input type="hidden" id="status" name="status" value="{$status}">
                                    <div class="form-group">
                                        <label class="col-sm-1 control-label" style="text-align:right;" for="batch_number">批次号：</label>
                                        <div class="col-sm-2 m-b-xs">
                                            <input type="text" id="batch_number" name="batch_number" value="{$batch_number}" class="form-control input-s-sm inline" placeholder="批次号">
                                        </div>
                                        <label class="col-sm-1 control-label" style="text-align:right;" for="real_name">姓名：</label>
                                        <div class="col-sm-2 m-b-xs">
                                            <input type="text" id="real_name" name="real_name" value="{$real_name}" class="form-control input-s-sm inline" placeholder="姓名">
                                        </div>
                                        <label class="col-sm-1 control-label" style="text-align:right;" for="user_phone">手机号：</label>
                                        <div class="col-sm-2 m-b-xs">
                                            <input type="text" id="user_phone" name="user_phone" value="{$user_phone}" class="form-control input-s-sm inline" placeholder="手机号">
                                        </div>
                                        <label class="col-sm-1 control-label" style="text-align:right;" for="idcard">身份证号：</label>
                                        <div class="col-sm-2 m-b-xs">
                                            <input type="text" id="idcard" name="idcard" value="{$idcard}" class="form-control input-s-sm inline" placeholder="身份证号">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="pull-left control-label col-sm-1" style="text-align:right;" for="update_time_start">更新时间：</label>
                                        <div class="col-sm-2">
                                            <input type="date" id="update_time_start" name="update_time_start"
                                                   value="{$update_time_start}"
                                                   class="form-control laydate-icon input-s-sm inline layer-date"
                                                   onclick="laydate({istime: false, format: 'YYYY-MM-DD'})">
                                        </div>
                                        <label class="pull-left control-label col-sm-1" style="text-align:center;" for="update_time_end">-</label>
                                        <div class="col-sm-2">
                                            <input type="date" id="update_time_end" name="update_time_end"
                                                   value="{$update_time_end}"
                                                   class="form-control laydate-icon input-s-sm inline layer-date"
                                                   onclick="laydate({istime: false, format: 'YYYY-MM-DD'})">
                                        </div>
                                        <label class="col-sm-1 control-label" style="text-align:right;" for="left_duration">剩余期限：</label>
                                        <div class="col-sm-2 m-b-xs">
                                            <select id="left_duration" name="left_duration" class="form-control input-s-sm inline">
                                                <option value="0" {if ($left_duration == 0)} selected {/if}>全部</option>
                                                <option value="1" {if ($left_duration == 1)} selected {/if}>60天及以内</option>
                                                <option value="2" {if ($left_duration == 2)} selected {/if}>60-150天</option>
                                                <option value="3" {if ($left_duration == 3)} selected {/if}>150-300天</option>
                                                <option value="4" {if ($left_duration == 4)} selected {/if}>300天以上</option>
                                            </select>
                                        </div>                                        
                                        <div class="col-sm-1">
                                            <button class="btn btn-primary" type="submit">查询</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <table class="table table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>批次号</th>
                                        <th>姓名</th>
                                        <th>手机号</th>
                                        <th>身份证号 </th>
                                        <th>在贷余额</th>
                                        <th>借款金额</th>
                                        <th>借款期限（天）</th>
                                        <th>剩余期限（天）</th>
                                        <th>车辆评估值（元）</th>
                                        <th>放款评估金额</th>
                                        <th>还款方式</th>
                                        <th>状态 </th>
                                        <th>更新时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="tbody_content">
                                    {if ($list)}
                                    {foreach $list as $key => $val} 
                                    <tr class="gradeA odd">
                                        <td>{$key + 1}</td>
                                        <td>{$val['batch_number']}</td>
                                        <td>{$val['real_name']}</td>
                                        <td>{$val['user_phone']}</td>
                                        <td>{$val['idcard']}</td>
                                        <td>{$val['left_money']}</td>
                                        <td>{$val['amount']}</td>
                                        <td>{$val['duration']}</td>
                                        <td>{$val['left_duration']}</td>
                                        <td>{$val['car_price']}</td>
                                        <td>{$val['money']}</td>
                                        <td>{$val['repayment_type']}</td>
                                        <td>{$val['status']}</td>
                                        <td>
                                            {if (strtotime($val['update_time']))}
                                                {$val['update_time']}
                                            {/if}
                                        </td>
                                        <td>
                                            <a href="{:url('Management/carDetail',['id'=>$val['id']])}" class="btn btn-info">详情</a>
                                        </td>
                                    </tr>
                                    {/foreach}                            
                                    {else /}
                                    <tr class="gradeA odd">
                                        <td style="text-align:center;" colspan="15">没有找到符合条件的记录</td>
                                    </tr>
                                    {/if}
                                </tbody>
                                <tfoot>
                                </tfoot>
                            </table>
                            {//分页}
                            <div>
                                <div id="page_list" class="row">
                                    {$paginator}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script>
            $(function () {
                //分页ajax请求
                $("#page_list").on("click",".paginate_button",function () {
                    $(this).addClass("active").siblings().removeClass("active");
                    var page = $(this).find("a").attr("page");
                    $("#page-now").val(page);
                    var formData = $("form").serialize();
                    $.ajax({
                        type:'post',
                        url:"{:url('Management/carAjax')}",
                        //    dataType:'json',
                        data:formData,
                        success: function(data){
                            $("#tbody_content").html("");
                            if(data.code == 0){
                                $("#tbody_content").html(data.data.html);
                                $("#page_list").html(data.data.page_list);
                                $("#type").html(data.data.type);
                                $("#status").html(data.data.status);
                            }
                        }
                    });
                    console.log(formData);
                });
            });
        </script>
    </body>
</html>
